﻿@model HdipCricketClub.ViewModels.ScorecardAbandonedFixtureReInputScoresBatAndBowlViewModel
@{
    ViewBag.Title = "ReInputEditAbandonedFixtureScoresBattedOnly";
}
<h2>
    Re Input Edit Abandoned Fixture Scores, Batted Only</h2>
@using (@Html.BeginForm("UpdateScores", "Scorecard", FormMethod.Post))
{
    <fieldset>
        <legend>Fixture</legend>
        <br />
        @Html.HiddenFor(ModelItem => Model.ScorecardFixture.fixture_id)
        @Html.HiddenFor(ModelItem => Model.ScorecardFixture.team_id)
        @Html.HiddenFor(ModelItem => Model.ScorecardFixture.opponent_id)
        @Html.HiddenFor(ModelItem => Model.ScorecardFixture.type)
        @Html.HiddenFor(ModelItem => Model.ScorecardFixture.home)
        @Html.HiddenFor(ModelItem => Model.ScorecardFixture.date)
        @Html.HiddenFor(ModelItem => Model.ScorecardFixture.start_time)
        @Html.HiddenFor(ModelItem => Model.ScorecardFixture.no_of_players)
        @Html.HiddenFor(ModelItem => Model.ScorecardHeaderDetail.fixture_id)
        @Html.HiddenFor(ModelItem => Model.ScorecardHeaderDetail.result_id)
        @Html.HiddenFor(ModelItem => Model.ScorecardHeaderDetail.scorecard_entered)
        @Html.HiddenFor(ModelItem => Model.ScorecardHeaderDetail.won_toss)
        @Html.HiddenFor(ModelItem => Model.ScorecardHeaderDetail.batted_first)
        @Html.HiddenFor(ModelItem => Model.ScorecardHeaderDetail.batted)
        @Html.HiddenFor(ModelItem => Model.ScorecardHeaderDetail.bowled)
        <br />
        @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Team.Club.ShortName) @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Team.name)
        vs @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Opponent.club_name) @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Opponent.team_name)
        <br />
        Played on: @Html.DisplayFor(ModelItem => Model.ScorecardFixture.date)
        <br />
        At:
        @if (Model.ScorecardFixture.home)
        {
            @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Team.Club.ShortName)
        }
        else
        {
            @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Opponent.club_name)
        }
        <br />
        <br />
        @if (Model.ScorecardHeaderDetail.won_toss)
        {
            @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Team.Club.ShortName)
            @:won the toss and elected to bat.
}
        else
        {
            @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Opponent.club_name)
            @:won the toss and elected to field first.
        }
    </fieldset>
    <fieldset>
        <legend>Innings of @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Team.Club.ShortName)</legend>
        <br />
        @if (Model.ScorecardClubErrorMessages.Count() > 0)
        {
            @:Please correct the following scorecard errors<br/>
        foreach (var item in Model.ScorecardClubErrorMessages)
        {
            @Html.DisplayFor(modelItem => item)<br />
        }
        }
        @if (Model.ClubBatsmenErrorMessages.Count() > 0)
        {
            @:Please correct the following batsman errors<br/>
        foreach (var item in Model.ClubBatsmenErrorMessages)
        {
            @Html.DisplayFor(modelItem => item)<br />
        }
        }
        <br />
        <table>
            <tr>
                <th>
                </th>
                <th>
                    Name
                </th>
                <th>
                    How Out
                </th>
                <th>
                    Fielder
                </th>
                <th>
                    Bowler
                </th>
                <th>
                    Runs
                </th>
            </tr>
            @foreach (var item in Model.ClubBatsmen)
            {
                <tr>
                    @Html.HiddenFor(modelItem => item.fixture_id)
                    @Html.HiddenFor(modelItem => item.player_id)
                    @Html.HiddenFor(modelItem => item.batsman_number)
                    <td class="column_ids">
                        @Html.DisplayFor(modelItem => item.batsman_number)
                    </td>
                    <td class="column_names">
                        @Html.EditorFor(modelItem => item.Member.InitialAndLastName)
                    </td>
                    <td class="column_names">
                        @if (item.how_out == null)
                        {
                            @Html.DropDownListFor(modelitem => item.how_out, new SelectList(Model.DismissalTypes, "dismissal_id", "type"), string.Empty)
                        }
                        @if (item.how_out != null)
                        {
                            @Html.DropDownListFor(modelitem => item.how_out, new SelectList(Model.DismissalTypes, "dismissal_id", "type", item.how_out), string.Empty)
                        }
                    </td>
                    <td class="column_names">
                        @if (item.fielder_name == null)
                        {
                            @Html.DropDownListFor(modelItem => item.fielder_name, new SelectList(Model.OpponentBatsmen, "op_player_name", "op_player_name"), string.Empty)
                        }
                        @if (item.fielder_name != null)
                        {
                            @Html.DropDownListFor(modelItem => item.fielder_name, new SelectList(Model.OpponentBatsmen, "op_player_name", "op_player_name", item.fielder_name), string.Empty)
                        }
                    </td>
                    <td class="column_names">
                        @if (item.bowler_name == null)
                        {
                            @Html.DropDownListFor(modelItem => item.bowler_name, new SelectList(Model.OpponentBowlers, "op_player_name", "op_player_name"), string.Empty)
                        }
                        @if (item.bowler_name != null)
                        {
                            @Html.DropDownListFor(modelItem => item.bowler_name, new SelectList(Model.OpponentBowlers, "op_player_name", "op_player_name", item.bowler_name), string.Empty)
                        }
                    </td>
                    <td class="column_numbers">
                        @Html.EditorFor(modelItem => item.batting_runs)
                    </td>
                </tr>
            }
            <tr>
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
                <td>
                    Sub Total
                </td>
                <td>
                </td>
                <td class="column_numbers">
                    @Html.DisplayFor(ModelItem => Model.TotalClubBatsmenRuns)
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
                <td>
                    Byes:
                </td>
                <td class="column_numbers">
                    @Html.EditorFor(ModelItem => Model.ClubOtherDetail.byes)
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
                <td>
                    Leg Byes:
                </td>
                <td class="column_numbers">
                    @Html.EditorFor(ModelItem => Model.ClubOtherDetail.leg_byes)
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
                <td>
                    Wides:
                </td>
                <td class="column_numbers">
                    @Html.EditorFor(ModelItem => Model.ClubOtherDetail.wides)
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
                <td>
                    No Balls:
                </td>
                <td class="column_numbers">
                    @Html.EditorFor(ModelItem => Model.ClubOtherDetail.no_balls)
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
                <td>
                    Total Extras:
                </td>
                <td>
                </td>
                <td class="column_numbers">
                    @Html.DisplayFor(ModelItem => Model.TotalClubExtras)
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
                <td>
                    Total Score For : @Html.DisplayFor(ModelItem => Model.ClubOtherDetail.wickets_lost)
                    wkts
                </td>
                <td>
                </td>
                <td class="column_numbers">
                    @Html.DisplayFor(ModelItem => Model.ClubOtherDetail.total_runs)
                </td>
            </tr>
        </table>
        <br />
        @if (Model.ClubOtherDetailErrorMessages.Count() > 0)
        {
            @:Please correct the following errors<br/>
        foreach (var item in Model.ClubOtherDetailErrorMessages)
        {
            @Html.DisplayFor(modelItem => item)<br />
        }
        }
        @if (Model.OpponentBowlersErrorMessages.Count() > 0)
        {
            @:Please correct the following bowler errors<br/>
        foreach (var item in Model.OpponentBowlersErrorMessages)
        {
            @Html.DisplayFor(modelItem => item)<br />
        }
        }
        <br />
        <table>
            <tr>
                <th>
                </th>
                <th>
                    Name:
                </th>
                <th>
                    Overs:
                </th>
                <th>
                    Maidens:
                </th>
                <th>
                    Runs:
                </th>
                <th>
                    Wickets:
                </th>
            </tr>
            @foreach (var item in Model.OpponentBowlers)
            {
                <tr>
                    @Html.HiddenFor(modelItem => item.op_fixture_id)
                    @Html.HiddenFor(modelItem => item.op_batsman_number)
                    @Html.HiddenFor(modelItem => item.op_bowler_number)
                    @Html.HiddenFor(modelItem => item.op_player_name)
                    <td class="column_ids">
                        @Html.DisplayFor(modelItem => item.op_bowler_number)
                    </td>
                    <td class="column_names">
                        @Html.DisplayFor(modelItem => item.op_player_name)
                    </td>
                    <td class="column_numbers">
                        @Html.EditorFor(modelItem => item.op_overs)
                    </td>
                    <td class="column_numbers">
                        @Html.EditorFor(modelItem => item.op_maidens)
                    </td>
                    <td class="column_numbers">
                        @Html.EditorFor(modelItem => item.op_bowling_runs)
                    </td>
                    <td class="column_numbers">
                        @Html.EditorFor(modelItem => item.op_wickets)
                    </td>
                </tr>
            }
        </table>
    </fieldset>
    <fieldset>
        <legend>@Html.DisplayFor(ModelItem => Model.ScorecardFixture.Opponent.club_name) team</legend>
        <br />
        @foreach (var item in Model.OpponentBatsmen)
        {
            @Html.HiddenFor(modelItem => item.op_fixture_id)
            @Html.HiddenFor(modelItem => item.op_batsman_number)
            @Html.HiddenFor(modelItem => item.op_player_name)
            @Html.DisplayFor(modelItem => item.op_player_name)@:,
            }
        <br />
    </fieldset>
    <p>
        <input type="submit" value="Save Changes" />
    </p>   
}